String.prototype.cnLength = function() {
	var arr = this.match(/[^\x00-\xff]/ig);
	return this.length + (arr == null ? 0 : arr.length);
};

String.prototype.cnLength2 = function() {
	var len = 0;
	var ch;
	for (var i = 0; i < this.length; i++) {
		ch = this.charCodeAt(i);
		if (ch >= 0 && ch <= 255) {
			len++;
		}
		else {
			len += 2;
		}
	}
	return len;
};